import time

def file_read(fname):
    x = open(fname).readlines()
    x = [int(el) for el in x]
    return x

def bubble(x):
    for i in range(len(a) - 1):
        swap = False
        for j in range(len(a) - 1 - i):
            if a[j] > a[j + 1]:
                swap = True
                a[j], a[j + 1] = a[j + 1], a[j]
        if swap: return

m1 = file_read('m1_sorted.txt')
m2 = file_read('m2_reverse.txt')
m3 = file_read('m3_shuffle.txt')

start = time.time()
bubble(m1)
stop = time.time()
duration = round((stop - start) * 1000)
print(f'm1_sorted {duration} milliseconds')

start = time.time()
bubble(m2)
stop = time.time()
duration = round((stop - start) * 1000)
print(f'm2_reverse {duration} milliseconds')

start = time.time()
bubble(m3)
stop = time.time()
duration = round((stop - start) * 1000)
print(f'm3_shuffle {duration} milliseconds')
                
